package com.example.ch02.lifecycle;

import android.os.Bundle;
import android.util.Log;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private static final String ACTIVITY_TAG = MainActivity.class.getSimpleName();

    private void showLog(String text) {
        Log.d(ACTIVITY_TAG, text);
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        showLog("Activity Created");
    }

    @Override
    protected void onRestart() {
        super.onRestart();//call to restart after onStop
        showLog("Activity restarted");
    }

    @Override
    protected void onStart() {
        super.onStart();//soon be visible
        showLog("Activity started");
    }

    @Override
    protected void onResume() {
        super.onResume();//visible
        showLog("Activity resumed");
    }

    @Override
    protected void onPause() {
        super.onPause();//invisible
        showLog("Activity paused");
    }

    @Override
    protected void onStop() {
        super.onStop();
        showLog("Activity stopped");
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        showLog("Activity is being destroyed");
    }
}